<?php
/* Clase del formulario FrmRolEdit que permite editar los roles de usuarios
 */
class FrmRolEdit{
	private $rol;
	private $setter;
	private $dbOperator;
	private $easyForm;
	private $frmTableRoles;
	private $div;
	
	function __construct($rol){
		$this->rol=new Rol();
		$this->rol=$rol;
		$this->setter=new Setter("../Config");
		$this->easyForm=new EasyForm("frmRoles","frmRoles","get", "../Events/EventsFrmRolEdit.php","Editar rol de usuario:","", "", "");
		$this->easyForm->addInput(3,"Nombre:", "nombreRolEdit", "nombreRolEdit","", "yes", "", "", "form", "", "", array());
		$this->easyForm->setItem("Nombre:",$this->rol->getNombre());
		
		$this->easyForm->addSimpleLabel(1, "Espacio0:", $id="espacio", $text="", $events=array());
		//$this->easyForm->addSimpleLabel(1, "Espacio1:", $id="espacio", $text="", $events=array());
		$this->easyForm->addSimpleLabel(2, "Secciones:", $id="secciones", $text="Secciones disponibles:", $events=array());
		//$this->easyForm->addSimpleLabel(1, "Espacio2:", $id="espacio", $text="&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;", $events=array());
		//$this->easyForm->addSimpleLabel(1, "Espacio3:", $id="espacio", $text="&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;", $events=array());
		//Listar las secciones disponibles
		$checkBoxes="";
		foreach ($this->setter->getSections() as $section){
			$this->easyForm->addCheckBox(1,$section,$section."Edit",$section."Edit","yes","","","","");
			if(in_array($section,$this->rol->getSections())){
				$this->easyForm->setItem($section,"checked");
			}
			$checkBoxes=$checkBoxes."'".$section."Edit"."',";
		}
		$checkBoxesFixed=substr($checkBoxes,0,strlen($checkBoxes)-1);
		//--------------------------------
		
		$this->easyForm->addTextArea(1,"Descripcion:","25","1","descripcionRolEdit","descripcionRolEdit");
		$this->easyForm->setItem("Descripcion:",$this->rol->getDescripcion());
		
		$this->easyForm->addSimpleLabel(1, "Espacio3:", $id="espacio", $text="", $events=array());
		
		$this->easyForm->addHidden(1,"idRol:","idRolEdit","idRolEdit",$this->rol->getId());
		$this->easyForm->addSimpleLabel(1, "Espacio4:", $id="espacio", $text="", $events=array());
		
		$this->easyForm->addButton(1,"editar:","EditarR","EditarR","editarR","editar","editar rol","button","","button","","Actualizar información","","","0", array("onclick"=>"GETMethodSend(".$checkBoxesFixed.",'nombreRolEdit','descripcionRolEdit','idRolEdit',this.id,'tableRoles','../Events/EventsFrmRolEdit.php')"));			
		$this->easyForm->addButton(1,"cancelar:","CancelEditarR","CancelEditarR","cancelEditarR","cancelar","cancelar editar rol","button","","button","","Cancelar Actualizar información","","","0", array("onclick"=>"GETMethodSend('CancelEditarR',this.id,'tableRoles','../Events/EventsFrmRolEdit.php')"));			
		
		$this->div=new Div("editarRolDiv", "editarRolDiv", "forms",array(),"220","600","150","150","hidden");
		$this->div->setVisibility("visible");
		$this->div->setMobile("mobile");
	}
	function show(){
		$this->div->start();
			$this->easyForm->show(2,8);
		$this->div->end();
	}
}

?>